<div class="row-fluid">
    <div class="table-header">
        Danh sách user
        <div class="pull-right">
            <a class="btn btn-small btn-success" href='<?php echo site_url("/usermanage/create")?>'>Thêm <i class="icon-arrow-right icon-on-right bigger-110"></i></a>
        </div>
    </div>
    <table id="table_report" class="table table-striped table-bordered table-hover dataTable">
        <thead>
            <tr>
                <th>Tên đăng nhập</th>
                <th>Mail</th>
                <th>Duyệt</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($lstUser as $user) {?>
                <tr>
                    <td><?php echo $user->Username ?></td>
                    <td><?php echo $user->Email ?></td>
                    <td>
                        <input data-id='<?php echo $user->Id ?>' <?php if($user->IsActive) echo "checked" ?> class="ace-switch approval" type="checkbox">
                        <span class="lbl"></span>
                    </td>
                    <td></td>
                </tr>
            <?php } ?>
        </tbody>

    </table>
</div>

<script type="text/javascript">
        $(document).ready(function () {

            // alert('ready');

            $("body").on("change", ".approval", function () {

                var id = $(this).attr("data-id");

                $.ajax({
                    url: '<?php echo site_url("/usermanage/Active")?>' + '/' + id,
                    contentType: 'application/json; charset=utf-8',
                    // data: {'userId': id},
                    dataType: 'text',
                    type: "POST"
                }).done(function (response, textStatus, jqXHR) {
                    console.log("done");

                    var htmlFriend = "<li class='notify-require-friend'>"
                                          + "<a>"
                                            + "<button type='button' class='close' aria-hidden='true'>&times;</button>"
                                            + "<p>Bạn đã thực hiện thành công!</p>"
                                          + "</a>"
                                       + "</li>";

                    $("#notify-bottom-left").prepend(htmlFriend);

                    $("#notify-bottom-left li").delay(5000).fadeOut('slow', "swing");

                    new Audio("<?php echo base_url('sound/notify_friend.FLV') ?>").play();                    

                }).fail(function (response, textStatus, jqXHR) {
                    console.log("fail");
                }); // end .ajax
            }); // end on
        }); // end ready

</script>
